package com.tt.aile.item.mapper;

import com.tt.aile.item.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 86176 shkstrat
 * @date 2020/9/21 - 21:22
 */
public interface BrandMapper extends Mapper<Brand> {

    /**
     * 新增商品分类和品牌中间表数据
     * @param cid 商品分类id
     * @param bid 品牌id
     * @return
     */
    @Insert("INSERT INTO tb_category_brand (category_id, brand_id) VALUES (#{cid},#{bid})")
    int insertCategoryBrand(@Param("cid")Long cid,@Param("bid") Long bid);


    @Select("SELECT * from tb_brand a INNER JOIN tb_category_brand b ON a.id = b.brand_id WHERE b.category_id=#{cid}")
    List<Brand> queryBrandByCid(@Param("cid") long cid);
}
